// pages/personCenter/personCenter.js
const user = require("../../models/user")
Page({
  data: {
    value:""
  },

  onLoad: async function (options) {
    var id = wx.getStorageSync('id');
    if(id){
      var data = await user(id);
      this.setData({
        value:data.data.res[0]
      })
    }
  },
  async onShow(){
    var id = wx.getStorageSync('id');
    if(id){
      var data = await user(id);
      this.setData({
        value:data.data.res[0]
      })
    }
  },
  // 登录
  login(){
    wx.navigateTo({
      url: '../login/login'
    })
  },
  out(){
    wx.removeStorageSync('id')
    this.setData({
      value:''
    });
    wx.showToast({
      title: '退出成功',
      icon: ''
    });
  },
  // 跳转功能
  toCart(){
    wx.switchTab({
      url: '../cart/cart'
    });
  },
  toCollect(){
    wx.navigateTo({
      url: '../collections/collections'
    });
  },
  toHistory(){
    wx.navigateTo({
      url: '../history/history'
    });
  },
  toPaid(){
    wx.navigateTo({
      url: '../paid/paid'
    });
  },
})